﻿using System;
using System.Collections.Generic;

namespace QDT.Core.Projects.LoanAlgorithm
{
    /// <summary>
    /// 所有利息算法的抽象类，所有的利息算法都必须实现此类
    /// </summary>
    public abstract class AbstractLoanAlgorithm : ILoanAlgorithm {

        protected AbstractLoanAlgorithm(decimal principal, double rate) {
            Principal = principal;

            Rate = rate;
        }

        protected AbstractLoanAlgorithm(Project project):this(project.BorrowAmount,project.Rate) {
            
        }

        /// <summary>
        /// 本金
        /// </summary>
        public decimal Principal { get; private set; }

        /// <summary>
        /// 年化率
        /// </summary>
        public double Rate { get; private set; }

        /// <summary>
        /// 总的利息
        /// </summary>
        /// <returns></returns>
        public abstract decimal TotalInterest { get; }

        /// <summary>
        /// 偿还总额
        /// </summary>
        public decimal TotalRepayAccount { get { return Principal + TotalInterest; } }

        /// <summary>
        /// 获得还款模型表
        /// </summary>
        /// <returns></returns>
        public abstract ICollection<RepayModel> GetModelTable(DateTime startTime);
    }
}